package com.pisolution.scheduler.runtime.quartz;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 从配置文件中读取定时调度服务相关配置.
 *
 * @author sora
 * @version 0.1.0
 */
@Component
@PropertySource(value = "classpath:quartz.properties")
public class QuartzConfig {
    /** 多客户端存在时的区分码. */
    @Value(value = "${scheduler.instance.name:pi-scheduler}")
    private String instanceName;

    /** 调度程序唯一标识 默认为自动生成. */
    @Value(value = "${scheduler.instance.id:AUTO}")
    private String instanceId;

    /** 调度线程名称. */
    @Value(value = "${scheduler.thread.name:quartz-daemon-thread}")
    private String threadName;

    /** 调度程序主线程是否为守护线程. */
    @Value(value = "${scheduler.thread.daemon:true}")
    private String isDaemon;

    /** 线程池中可用于并发执行作业的线程数. */
    @Value(value = "${scheduler.thread.pool.size:25}")
    private String threadPoolSize;

    /** 线程池中调度线程优先级 默认为5. */
    @Value(value = "${scheduler.thread.pool.priority:5}")
    private String threadPoolPriority;

    /** 是否将线程池中的线程创建为守护线程. */
    @Value(value = "${scheduler.thread.pool.daemon:true}")
    private String isThreadPoolDaemon;

    /** 用于任务存储的自定义数据源名称. */
    @Value(value = "${scheduler.job.store.datasource.name:ds}")
    private String datasourceName;

    /** 用于存储任务数据的表前缀. */
    @Value(value = "${scheduler.job.store.table.prefix:QUARTZ_}")
    private String tablePrefix;

    /** 调度程序在被认为是误触发之前 将容忍触发器经过下一次触发时间的毫秒数. */
    @Value(value = "${scheduler.job.store.misfire.threshold:60000}")
    private String misFireThreshold;

    /** 此实例与其他群集实例签入的频率. */
    @Value(value = "${scheduler.job.store.checkin.interval:5000}")
    private String checkinInterval;

    // -------------------------------------------------------------------------------------------------
    //  属性访问
    // -------------------------------------------------------------------------------------------------

    public String getInstanceName() {
        return this.instanceName;
    }

    public String getInstanceId() {
        return this.instanceId;
    }

    public String getThreadName() {
        return this.threadName;
    }

    public String getDaemon() {
        return this.isDaemon;
    }

    public String getThreadPoolSize() {
        return this.threadPoolSize;
    }

    public String getThreadPoolPriority() {
        return this.threadPoolPriority;
    }

    public String getIsThreadPoolDaemon() {
        return this.isThreadPoolDaemon;
    }

    public String getDatasourceName() {
        return this.datasourceName;
    }

    public String getTablePrefix() {
        return this.tablePrefix;
    }

    public String getMisFireThreshold() {
        return this.misFireThreshold;
    }

    public String getCheckinInterval() {
        return this.checkinInterval;
    }
}
